//
//  NSMutableArray+BZSafe.h
//  BZFoundation
//
//  Created by 郭艺伟 on 2017/9/30.
//  Copyright © 2017年 郭艺伟. All rights reserved.
//

#import <Foundation/Foundation.h>

#ifndef BZArrayAddObject
#define BZArrayAddObject(array, object)   \
if (object) {         \
[(array) addObject:(object)];  \
}
#endif

#ifndef BZArrayInsertObjectAtIndex
#define BZArrayInsertObjectAtIndex(array, object, index)                       \
if ((object) && (index) <= [(array) count] && (index) >= 0) {          \
[(array) insertObject:(object) atIndex:(index)];                   \
}
#endif

#ifndef BZArrayObjectAtIndex
#define BZArrayObjectAtIndex(array, index)                                     \
((index) < [(array) count] && (index) >= 0 ?                           \
[(array) objectAtIndex:(index)] : nil)
#endif

#ifndef BZArrayRemoveObjectAtIndex
#define BZArrayRemoveObjectAtIndex(array, index)                               \
if ((index) < [(array) count] && (index) >= 0) {                       \
[(array) removeObjectAtIndex:(index)];                             \
}
#endif

#ifndef BZArrayReplaceObjectAtIndex
#define BZArrayReplaceObjectAtIndex(array, object, index)                      \
if ((object) && (index) < [(array) count] && (index) >= 0) {           \
[(array) replaceObjectAtIndex:(index) withObject:(object)];        \
}
#endif

@interface NSMutableArray (BZSafe)

@end
